package com.bgs.config.publisherDirect;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class BeforeDirectConfig {
    public static final String direct_Exchange_name = "zero.publisherDirect.returnGoods.exchange";
    public static final String direct_ROUTING_KEY_name = "returngoodsKey";

    //创建交换机
    @Bean
    DirectExchange directExchange() {
        return new DirectExchange(direct_Exchange_name);
    }

    @Bean
    Queue queue() {
        return new Queue("zero.publisherDirect.returnGoods.queue");
    }

    @Bean
    Binding binding() {
        return BindingBuilder.bind(queue()).to(directExchange()).with(direct_ROUTING_KEY_name);
    }
}
